package net.huashitong.user.dao;

import org.springframework.stereotype.Repository;

import net.huashitong.user.entity.SysValid;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.core.filter.BaseFilter;

@Repository
public class SysValidDao extends StringDao<SysValid> {

	public SysValid getByMobile(String mobile) {
		GenericQuery query = createQuery("obj");
		query.append(" and obj.mobile = :mobile").setParam("mobile", mobile);
		query.getOrders().put("sysId", BaseFilter.DESC);
		return query.firstResult();
	}

	public SysValid getValidCodeByMobile(String mobile){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.mobile = :mobile").setParam("mobile", mobile);
		query.append(" order By obj.timestamp+0 desc");
		return query.firstResult();
	}

}
